package com.zhl.media.app.utils;

import android.content.Context;

import com.birbit.android.jobqueue.JobManager;
import com.birbit.android.jobqueue.config.Configuration;
import com.zhl.media.app.greendao.AdJustDao;
import com.zhl.media.app.greendao.ElevatorDao;
import com.zhl.media.app.greendao.MediaPhotoDao;
import com.zhl.media.app.greendao.MediaPositionDao;
import com.zhl.media.app.greendao.ProjDao;
import com.zhl.media.app.mvp.ui.activity.FileUploadActivity;


public class TaskJobManager {

    private static TaskJobManager taskJobManager;

    private Context context;

    private JobManager jobManager;

    public TaskJobManager(Context context) {
        this.context = context;
    }

    public void init(){
        jobManager = new JobManager(new Configuration.Builder(context).minConsumerCount(1).maxConsumerCount(1).loadFactor(1).consumerKeepAlive(1200).build());
    }

    public JobManager getJobManager() {
        if(jobManager==null) {
            jobManager = new JobManager(new Configuration.Builder(context).minConsumerCount(1).maxConsumerCount(1).loadFactor(1).consumerKeepAlive(1200).build());
        }
        return jobManager;
    }

    /**
     * 创建单例
     * @return
     */
    public static TaskJobManager getInstance(Context context) {
        if (taskJobManager == null) {
            taskJobManager = new TaskJobManager(context);
        }
        return taskJobManager;
    }
}